<?php
/**
 * Framework_Util_DataCheck
 *
 * 
 *
 * @package BAMF
 */

class Framework_Util_DataCheck {


	/**
	 * emptyNotZero
	 *
	 * Returns true if the value is either zero or non-empty
	 *
	 * @param		mixed $value The value to check
	 *
	 * @return		boolean 
	 *
	 * @package BAMF
	 * @subpackage Framework_Util
	 * 
	 */
	public static function emptyNotZero($value) {
		$_output = false ;

		if (empty($value)) {
			if (!is_numeric($value)) {
				$_output = true ;
			}
		}

		return $_output ;
	}


	/**
	 * isAlphanumeric
	 *
	 * Returns true if the value is an alphanumeric string
	 *
	 * @param		mixed $aString The value to check
	 * @param		mixed $allowUnderscore Whether to consider "_" as alphanumeric.
	 *
	 * @return		boolean 
	 *
	 * @package BAMF
	 * @subpackage Framework_Util
	 * 
	 */
	public static function isAlphanumeric( $aString=null, $allowUnderscore=true ) {
		$isAlphanumeric = false ;

		if( !empty( $aString )) {
			if( $allowUnderscore ) {
				if( !preg_match( "/[^a-zA-Z0-9\_]/", $aString )) {
					$isAlphanumeric = true ;
				}
			} else {
				if( !preg_match( "/[^a-zA-Z0-9]/", $aString )) {
					$isAlphanumeric = true ;
				}
			}
		}

		return $isAlphanumeric ;

	}

}


?>
